home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 18 / fpc103.zip / TOPEDIT.SEQ < prev    next >
Text File  |  1988-06-14  |  3KB  |  100 lines

  1. \ TOPEDIT.SEQ   Memory edit.                            By Tom Zimmer
  2.  
  3. comment:
  4.  
  5.   Memory edit, allows reentering the editor without having to re-read
  6. the edit file from disk. This results in a much faster turn around time
  7. for development.  Changes made during an edit will still be saved at
  8. the end of each edit session.
  9.  
  10. comment;
  11.  
  12. only forth also editor also hidden definitions also
  13.  
  14. handle memfile
  15.  
  16. : ?readfile     ( --- )
  17.                 edinit
  18.                 shndl @ memfile over c@ 1+ comp         \ if file not the same
  19.                 edready @ 0= or                         \ or editor not ready
  20.                 if      read.oldfile                    \ read the file
  21.                         shndl @ memfile $>handle        \ copy to memfile
  22.                         sinit                           \ init mem structure
  23.                         edready on                      \ say everything ready
  24.                 then    ;
  25.  
  26. : cold-edinit        ( --- )
  27.                 defers initstuff
  28.                 memfile clr-hcb
  29.                 edready off ;
  30.  
  31. ' cold-edinit is initstuff
  32.  
  33. only forth definitions also editor also hidden also
  34.  
  35. : <ed>          ( --- )         \ Redefined to work from memory.
  36.                 ?fileopen
  37.                 ?readfile
  38.                 shndl @ hclose drop
  39.                 backingup @ renaming !
  40.                 8 scrline !
  41.                 reedit
  42.                 shndl @ memfile $>handle
  43.                 shndl @ hopen drop      \ Reopen file
  44.                 shndl+  clr-hcb ;       \ Clear out the handle above.
  45.  
  46. comment:
  47. : editany       ( --- )         \ watch out here !!
  48.                 byte|line on    \ Byte offset
  49.                 shndl @ hclose drop
  50.                 renaming off
  51.                 8 scrline !
  52.                 reedit
  53.                 shndl @ memfile $>handle
  54.                 shndl @ hopen drop      \ Reopen file
  55.                 shndl+  clr-hcb  ;      \ Clear out the handle above.
  56. comment;
  57.  
  58. : sed           ( --- )
  59.                 edinit
  60.                 byte|line on            \ Set to byte offset
  61.                 backingup @ renaming ! esed ;
  62.  
  63. : ed            ( --- )
  64.                 >in @ bl word c@ swap >in ! 0>
  65.                 shndl @ >hndle @ 0< and
  66.                 if      sed
  67.                 else    byte|line on    \ Byte offset
  68.                         <ed>
  69.                 then    cr ;
  70.  
  71. comment:
  72.  
  73.         \ This routine conflicts with the floating point name FIX, and is
  74.         \ thus commented out. You may add it back in if you wish.
  75.  
  76. : fix           ( t1 --- )
  77.                 view
  78.                 shndl @ >hndle @ 0>
  79.                 if      ed
  80.                 then    ;
  81. comment;
  82.  
  83. : edit          ( n1 --- )      \ redefined to work from memory.
  84.                 >in @ bl word c@ swap >in ! 0>
  85.                 shndl @ >hndle @ 0< and
  86.                 if      depth 0> if drop then sed
  87.                 else    1 ?enough
  88.                         byte|line off   \ Line to edit
  89.                         loadline !
  90.                         <ed>
  91.                 then    ;
  92.  
  93. : listing       ( --- )
  94.                 ?fileopen
  95.                 edinit renaming off elisting ;
  96.  
  97. only forth also definitions
  98.  
  99.  
  100.